home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: STRTOL, STRTUL,STRTOD functions
- Date: Fri, 29 Mar 96 23:55:09 GMT
- Organization: none
- Message-ID: <828143709snz@genesis.demon.co.uk>
- References: <4ifjao$j5c@news1.h1.usa.pipeline.com> <314ed2d3.110217@news.fred.net> <4ivnod$afn@access4.digex.net>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4ivnod$afn@access4.digex.net>
- igor@access4.digex.net "Dan White" writes:
-
- >>int main(void)
- >>{
- >> char *string = "87654321", *endptr;
- >> long lnumber;
- >>
- >> /* strtol converts string to long integer */
- >> /* strtoul converts a string to an unsigned long */
- >> /* strtod converts a string to a double */
- >>
- >> /* *endptr will point to the character that stopped the scan */
- >>
- >>
- >> lnumber = strtol(string, &endptr, 10);
- >>
- >> printf("string = %s long = %ld\n", string, lnumber);
- >>
- >> return 0;
- >>}
- >>
- >>
- >>Hope this helps,
- >
- >...and what is wrong with using sscanf ?
-
- What's wrong with using strtol? It is arguably the more direct and simpler
- function to use in this case. atol() is another possibility.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-